<?php

/**
 * @author dragon.hu add @2016.6.2
 */
defined('BASEPATH') or die('forbidden');

class rolerestore_controller extends Controller {
	
    function _init() {
        check_level(50, segment(0), segment(1), segment(2, 'index'));
    }

    function index() {
     if (is_submit()) {
            $rowdata = $_POST['row'];
            
            $areanum = $rowdata['area_host'];
            $rolename = $rowdata['role_name'];
            //var_dump($areanum);
            //var_dump($rolename);
            //exit();
            if (empty($areanum) || empty($rolename))
            	echo "<script>alert('param is empty!!!')</script>";
            
            $dbConn = getTmpDbConnect(PLATFORM_ALL, 'all', $areanum, DBTYPE_GAMESERVER);
            $sql = "UPDATE player SET isdelete = 0 WHERE name = '$rolename'";
            $res = $dbConn->execute($sql);
            
            if ($res === FALSE) {
            	echo "<script>alert('send failed！！！')</script>";
            }
            else
            {
            	echo "<script>alert('success！！！')</script>";
            }
        }
        $arealist = get_area_list_detal();
        $data = array();
        foreach ($arealist as $key=>$value)
        {
        	$data[$value['id']]=$value['id']."-".$value['name'];
        }
        	
        $this->view->assign("arealist", $this->form->select("row[area_host]", $data, '', array('id' => 'area_host')));
        $this->view->display("seal/rolerestore/index");
    }

}

?>
